sequenceDiagram
    participant Initiator
    participant ChannelInitiator
    participant StreamClient_I

    participant Stream_R_I
    participant Stream_I_R

    participant StreamClient_R
    participant ChannelListener
    participant ChannelResponder
    participant echoer
    participant Responder

    rect rgba(255, 0, 0, 0.1)
        Note over Initiator, StreamClient_I: Subscribe Initiator

        Initiator-->>StreamClient_I: create
        StreamClient_I--)Stream_R_I: pull
        StreamClient_I-->>Initiator: ok
    end

    loop
        Stream_R_I--)StreamClient_I: pull_response[]
        StreamClient_I--)Stream_R_I: pull
    end

    rect rgba(255, 0, 0, 0.1)
        Note over Responder, StreamClient_R: Subscribe Responder
        Responder-->>echoer: create
        Responder-->>StreamClient_R: create
        StreamClient_R--)Stream_I_R: pull
        StreamClient_R-->>Responder: ok
    end

    loop
        Stream_I_R--)StreamClient_R: pull_response[]
        StreamClient_R--)Stream_I_R: pull
    end


    rect rgba(0, 255, 0, 0.1)
        Note over Initiator, ChannelResponder: Secure channel negotiation
        Initiator-->>ChannelInitiator: create
        ChannelInitiator-->>StreamClient_I: init_channel
        StreamClient_I--)Stream_I_R: push[init_channel]
        Stream_I_R--)StreamClient_R: pull_response[init_channel]

        StreamClient_R-->>ChannelListener: init_channel
        ChannelListener-->>ChannelResponder: create
        ChannelResponder-->>StreamClient_R: handshake
        StreamClient_R--)Stream_R_I: push[handshake]

        Stream_R_I--)StreamClient_I: pull_response[handshake]
        StreamClient_I-->>ChannelInitiator: handshake

        ChannelResponder-->ChannelInitiator: handshake

        ChannelInitiator-->>Initiator: create_ok
    end

    Initiator->>ChannelInitiator: message
    ChannelInitiator->>StreamClient_I: encrypted[message]
    StreamClient_I--)Stream_I_R: push[encrypted[message]]
    Stream_I_R--)StreamClient_R: pull_response[encrypted[message]]
    StreamClient_R->>ChannelResponder: encrypted[message]
    ChannelResponder->>echoer: message

    echoer->>ChannelResponder: response
    ChannelResponder->>StreamClient_R: encrypted[response]
    StreamClient_R--)Stream_R_I: push[encrypted[response]]
    Stream_R_I--)StreamClient_I: pull[encrypted[response]]
    StreamClient_I->>ChannelInitiator: encrypted[response]
    ChannelInitiator->>Initiator: response
